package server;


import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Random;
import common.Constants;
import server.SubServer;


public class Server implements Runnable{


	private ServerSocket providerSocket;
	private Socket socket=null;
	private int playerNumber=0;
    public static String[][] mapReceive=new String[6][6];
    public static String[][] mapReceivee=new String[6][6];
    public static int countA=0;
    public static int countB=0;
    public static boolean isWin=false;
    public static String a;
	public static String b;
	
	public Server() throws IOException{
		providerSocket= new ServerSocket(Constants.PORT);
		System.out.println("waiting for client...");
	}

	public void run(){

		try {
			 
			    SubServer player = new SubServer();
				socket=providerSocket.accept();
				MyThread thread=new MyThread(player,socket);
				thread.setName(Integer.toString(playerNumber));
		        thread.start();
				playerNumber++;
				
		        socket=providerSocket.accept();
				MyThread threadd=new MyThread(player,socket);
				threadd.setName(Integer.toString(playerNumber));
			
		        threadd.start();
		        
			    System.out.print("two player ready.start!");
			    
			    
		
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.print("pro");
		}
	}

	public void IsWin(){
		
	}
	
	
	
	public static void main(String[] args) throws IOException{
		new Thread(new Server()).start();
	}

}
